-- Pierwotny właściciel i twórca kodu: AmaMa
-- Zakaz używania / edycji kodu bez wcześniejszej zgody ze strony właściciela
-- Zakaz wykorzystywania całego lub fragmentów kodu
-- W przypadku złamania powyzszych zasad sprawa zostanie skierowana do sądu pod zarzutem: Naruszenia majątkowych praw autorskich
-- Pierwotnie pełne prawo do używania tego kodu posiada tylko AmaMa

mojeW,mojeH = 1360,768
sW,sH = guiGetScreenSize()
sx, sy = (sW/mojeW), (sH/mojeH)
local screenW, screenH = guiGetScreenSize()
local font1 = dxCreateFont("f.ttf", 17*sx)
local font2 = dxCreateFont("f.ttf", 15*sx)
local font3 = dxCreateFont("f.ttf", 13*sx)
local font4 = dxCreateFont("f.ttf", 11*sx)
local font5 = dxCreateFont("f.ttf", 9*sx)
local font6 = dxCreateFont("f2.ttf", 30*sx)
local font7 = dxCreateFont("f2.ttf", 27*sx)
local font8 = dxCreateFont("f2.ttf", 24*sx)
local font9 = dxCreateFont("f2.ttf", 21*sx)
local font10 = dxCreateFont("f2.ttf", 18*sx)
local font11 = dxCreateFont("OSBI.ttf", 20*sx)
local font12 = dxCreateFont("OSBI.ttf", 17*sx)
local font13 = dxCreateFont("OSBI.ttf", 14*sx)
local font14 = dxCreateFont("OSBI.ttf", 11*sx)
local font15 = dxCreateFont("OSBI.ttf", 8*sx)
local font16 = dxCreateFont("OSB.ttf", 20*sx)
local font17 = dxCreateFont("OSB.ttf", 17*sx)
local font18 = dxCreateFont("OSB.ttf", 14*sx)
local font19 = dxCreateFont("OSB.ttf", 11*sx)
local font19v1 = dxCreateFont("OSB.ttf", 10*sx)
local font19v2 = dxCreateFont("OSB.ttf", 9*sx)
local font20 = dxCreateFont("OSB.ttf", 8*sx)

function fonts(f)
	if f == "font1" then t2font = font1 
	elseif f == "font2" then t2font = font2 
	elseif f == "font3" then t2font = font3 
	elseif f == "font4" then t2font = font4 
	elseif f == "font5" then t2font = font5 
	elseif f == "font6" then t2font = font6 
	elseif f == "font7" then t2font = font7 
	elseif f == "font8" then t2font = font8 
	elseif f == "font9" then t2font = font9 
	elseif f == "font10" then t2font = font10 
	elseif f == "font11" then t2font = font11 
	elseif f == "font12" then t2font = font12 
	elseif f == "font13" then t2font = font13 
	elseif f == "font14" then t2font = font14 
	elseif f == "font15" then t2font = font15 
	elseif f == "font16" then t2font = font16 
	elseif f == "font17" then t2font = font17 
	elseif f == "font18" then t2font = font18 
	elseif f == "font19" then t2font = font19 
	elseif f == "font19.1" then t2font = font19v1
	elseif f == "font19.2" then t2font = font19v2
	elseif f == "font20" then t2font = font20
	else t2font = font19
	end
end
	
	local xx = 30
	local xx2 = 20
	
	function isMouseIn(psx,psy,pssx,pssy,abx,aby)
		if not isCursorShowing() then return end
		cx,cy=getCursorPosition()
		cx,cy=cx*screenW,cy*screenH
		if cx >= psx and cx <= psx+pssx and cy >= psy and cy <= psy+pssy then
			return true,cx,cy
		else
			return false
		end
	end
	
	function createCustomWindow(txt,x,y,w,h)
		local r,g,b=interpolateBetween(225,0,80,100,0,255,(getTickCount()-tick)/2500,"CosineCurve")
		dxDrawImage(x,y,w,h,"window.png")
		dxDrawImage(x,y,w,h,"window2.png",0,0,0,tocolor(r,g,b,255))
		if txt ~= true then
			dxDrawText(txt, x+1, y+(math.floor(screenH * 0.014))+1, w+x+1, h+y+1, tocolor(0, 0, 0, 255), size, font2, "center", "top", false, true)
			dxDrawText(txt, x, y+(math.floor(screenH * 0.014)), w+x, h+y, tocolor(255, 255, 255, 255), size, font2, "center", "top", false, true)
		end
	end
	tick = getTickCount()
	function createCustomButton(txt,x,y,w,h,color,font)
		txt = string.gsub(txt, "ą", "a")
		txt = string.gsub(txt, "ę", "e")
		txt = string.gsub(txt, "ś", "s")
		txt = string.gsub(txt, "ć", "c")
		txt = string.gsub(txt, "ż", "z")
		fonts(font)
		if not color then color = tocolor(255,255,255,255) end
		local r,g,b=interpolateBetween(225,0,80,100,0,255,(getTickCount()-tick)/1100,"CosineCurve")
		if isMouseIn(x,y,w,h) then
			DxDrawBorderedRectangle(x,y,w,h, tocolor(0, 0, 0, 180), tocolor(r, g, b,255), 2, false) 
		else
			DxDrawBorderedRectangle(x,y,w,h, tocolor(0, 0, 0, 120), tocolor(100, 0, 255,255), 2, false) 
		end
		dxDrawText(txt, x+1, y+1, w+x+1, h+y+1, tocolor(0, 0, 0, 255), 1, t2font, "center", "center", false, true)
		dxDrawText(txt, x, y, w+x, h+y, color, 1, t2font, "center", "center", false, true)
	end
	prog1 = false
	prog2= false
	
	function createCustomButton2(txt,x,y,w,h)
		txt = string.gsub(txt, "ą", "a")
		txt = string.gsub(txt, "ę", "e")
		txt = string.gsub(txt, "ś", "s")
		txt = string.gsub(txt, "ć", "c")
		txt = string.gsub(txt, "ż", "z")
		if isMouseIn(x,y,w,h) then
			dxDrawImage(x,y,w,h,"button.png",0,0,0,tocolor(255,255,255,175))
		else
			dxDrawImage(x,y,w,h,"button.png",0,0,0,tocolor(255,255,255,255))
		end
		dxDrawText(txt, x+1, y+1, w+x+1, h+y+1, tocolor(0, 0, 0, 255), 1, font13, "center", "center", false, true)
		dxDrawText(txt, x, y, w+x, h+y, tocolor(255, 255, 255, 255), 1, font13, "center", "center", false, true)
	end
	
	function createCustomText2(txt,x,y,w,h,color,size,font,xx,yy,gui,cliped)
		if not xx then xx = "center" end
		if not yy then yy = "center" end
		if not color then color = tocolor(255,255,255) end
		fonts(font)
		local g = "#%x%x%x%x%x%x"
		local g1 = false
		if string.find(txt, g, 1) then
			g = string.gsub(txt, g, "")
			g1 = true 
		else
			g = txt
		end
		dxDrawText(g, x+1, y+1, w+1, h+1, tocolor(0, 0, 0), 1, t2font or "default-bold", xx, yy, false, cliped, false, g1)
		dxDrawText(txt, x, y, w, h, color, 1, t2font or "default-bold", xx, yy, false, cliped, false, g1)
	end
	
	function createCustomProgressBar(x,y,w,h,progress,color)
		dxDrawImage(x,y,w,h,"progress.png")
	end
	
	local tick = false
	local time = false
	local text = false
	
	function p()
		if (getTickCount()-tick) > time then
			fadeCamera(true)
			removeEventHandler("onClientRender", root, p)
		else
			local progress = interpolateBetween(0, 0, 0, 100, 0, 0, (getTickCount()-tick)/time, "Linear")
			createCustomProgressBar(text, progress)
		end
	end
	
	
	function DxDrawBorderedRectangle( x, y, width, height, color1, color2, _width, postGUI )
		local _width = _width or 1
		dxDrawRectangle ( x+1, y+1, width-1, height-1, color1, postGUI )
		dxDrawLine ( x, y, x+width, y, color2, _width, postGUI ) -- Top
		dxDrawLine ( x, y, x, y+height, color2, _width, postGUI ) -- Left
		dxDrawLine ( x, y+height, x+width, y+height, color2, _width, postGUI ) -- Bottom
		dxDrawLine ( x+width, y, x+width, y+height, color2, _width, postGUI ) -- Right
	end
	
	function isEventHandlerAdded( sEventName, pElementAttachedTo, func )
		 if type( sEventName ) == 'string' and isElement( pElementAttachedTo ) and type( func ) == 'function' then
			  local aAttachedFunctions = getEventHandlers( sEventName, pElementAttachedTo )
			  if type( aAttachedFunctions ) == 'table' and #aAttachedFunctions > 0 then
				   for i, v in ipairs( aAttachedFunctions ) do
						if v == func then
						 return true
					end
			   end
		  end
		 end
		 return false
	end
	
	function onCreateProgress(txt, tt)
		tick = getTickCount()
		time = tt
		text = txt
		fadeCamera(false)
		addEventHandler("onClientRender", root, p)
	end
	